#include "competitionmodel.h"

CompetitionModel::CompetitionModel(SystemController *controller, QObject *parent, QSqlDatabase db) : QSqlTableModel(parent, db)
{
    this->systemController = controller;
}

CompetitionModel::~CompetitionModel()
{
    this->database().close();
}


/*!
  \fn selectStatement
  Function which change the selectStatement, to set the order of the columns
  */
QString CompetitionModel::selectStatement() const
{
    QString stmt =  QSqlTableModel::selectStatement();
    int fromPos = stmt.lastIndexOf("FROM");

    QString newSelect = "SELECT \"cId\", \"name\", \"city\", \"date\", \"contactMail\", \"contactWeb\"";

    stmt = stmt.remove(0, fromPos);
    stmt = stmt.prepend(newSelect);

    return stmt;
}

